
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户注册</title>
</head>
<script type="text/javascript" src="../jquery-3.2.0.min.js"></script>
<script type="text/javascript">
function fun() {
	if($("#name").val()==""){
		alert("用户名不能为空!");
		return;
	}else{
		$.get("${pageContext.request.contextPath }/check",
			{name:$("#name").val(),
			time:new Date().getTime()},
			function(data){
				$("span").html(data);
			}
		)
	}
}

function changeImage() {
	$("img").attr("src","${pageContext.request.contextPath}/imageURL?time="+new Date().getTime())
}
</script>

<body>
<h1>用户注册</h1>
<form action="${pageContext.request.contextPath}/RegistServlet" method="post">
 name:<input type="text" name="name" id="name" onchange="fun()">
 <span></span>
 <br>
 password:<input type="text" name="password"><br>
 验证码：<input type="text" name="checkcode">
 <img alt="图片加载失败" src="${pageContext.request.contextPath}/imageURL" onclick="changeImage()"><br>
 <input type="submit" value="注册">
 <a href="login.jsp">登录</a>
</form>
</body>
</html>